package com.spring.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@Controller
public class FileUpload {

    @RequestMapping("/fileUpload")
    public String upload(String user, MultipartFile fileload) throws IOException {
        System.out.println(user);
        /* 文件上传处理*/

        /* 获取名字*/
        String originalFilename = fileload.getOriginalFilename();
        /*传入的路径*/
        fileload.transferTo(new File("C:\\Users\\z'j'j\\Desktop\\apache-tomcat-8.5.78\\apache-tomcat-8.5.78upload/"+originalFilename));

        return  "success";
    }


    @RequestMapping("/morefileUpload")
    public String Moreupload(String user, MultipartFile[] fileload) throws IOException {
        System.out.println(user);
        /* 文件上传处理*/
        for (MultipartFile multipartFile : fileload) {
            String originalFilename = multipartFile.getOriginalFilename();
            multipartFile.transferTo(new File("C:\\Users\\z'j'j\\Desktop\\apache-tomcat-8.5.78\\apache-tomcat-8.5.78upload/"+originalFilename));
        }

        return  "success";
    }


}
